use tokio::io;
use connect::adb;
use connect::proxy;
use tracing_appender;
use tracing_subscriber::fmt::Layer;
use tracing_subscriber::layer::SubscriberExt;
use tracing_subscriber::util::SubscriberInitExt;

const SOCKS_VERSION: u8 = 0x05;

#[tokio::main]
async fn main() -> io::Result<()> {
    let file_appender = tracing_appender::rolling::minutely("./log", "test.log");
    let (non_blocking, _guard) = tracing_appender::non_blocking(file_appender);
    tracing_subscriber::registry()
        .with(
            tracing_subscriber::EnvFilter::try_from_default_env().unwrap_or_else(|_| {
                format!("connect=debug,adb_client=debug").into()
            }),
        )
        .with(tracing_subscriber::fmt::layer())
        .with(Layer::default().with_writer(non_blocking).with_ansi(false))
        .init();

    // 监听adb
    tokio::spawn(async move {
        adb::run_adb();
    });

    proxy::run_proxy().await
}

